package com.liao.shengchanglon;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private int i = 3;
    private CountDownTimer countDownTimer = new CountDownTimer(3 * 1000, 1000) {
        @Override
        public void onTick(long millisUntilFinished) {
            tv_time.setText("跳过" + i--);
        }

        @Override
        public void onFinish() {
            startActivity(new Intent(MainActivity.this, Main2Activity.class));
            finish();
        }
    };

    TextView tv_time;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getSupportActionBar().hide();
        tv_time = findViewById(R.id.tv_time);
        tv_time.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                countDownTimer.cancel();
                startActivity(new Intent(MainActivity.this, Main2Activity.class));
                finish();
            }
        });
        countDownTimer.start();
    }
}
